<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
//use Illuminate\Support\Facades\Schema;

class HealthNote20230811 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('health_note', function (Blueprint $table) {
            $table->id();
            $table->string('title')->comment('标题');
            $table->longText('content')->comment('内容');
            $table->integer('pusher_id')->default(0)->comment('发布者ID');
            $table->integer('member_id')->default(0)->index()->comment('发布者ID');
            $table->string('belong_type')->comment('关联类型');
            $table->integer('belong_id')->comment('关联ID');
            $table->tinyInteger('examine_status')->default(0)->comment('状态 0-未审核 1-审核不通过 2-审核通过');
            $table->integer('examine_time')->default(0)->comment('审核时间');
            $table->integer('relay_count')->default(0)->comment('转发数');
            $table->integer('fav_count')->default(0)->comment('点赞数');
            $table->tinyInteger('is_show')->default(0)->comment('是否显示 0-否 1-是');
            $table->tinyInteger('is_hot')->default(0)->comment('是否推荐 0-否 1-是');
            $table->timestamps();
            $table->index(['belong_type', 'belong_id'], 'health_note_belong_index');
            $table->comment = '健康笔记表';
        });

        Schema::create('health_note_comments', function (Blueprint $table) {
            $table->id();
            $table->integer('note_id')->index()->comment('笔记ID');
            $table->integer('pusher_id')->index()->comment('发布者ID');
            $table->tinyInteger('examine_status')->default(0)->comment('状态 0-未审核 1-审核不通过 2-审核通过');
            $table->integer('examine_time')->default(0)->comment('审核时间');
            $table->integer('fav_count')->default(0)->comment('点赞数');
            $table->tinyInteger('is_show')->default(0)->comment('是否显示 0-否 1-是');
            $table->timestamps();
            $table->comment = '健康笔记评论表';
        });

        Schema::create('health_note_favorites', function (Blueprint $table) {
            $table->id();
            $table->integer('member_id')->index()->comment('会员ID');
            $table->integer('note_id')->index()->comment('笔记ID');
            $table->timestamps();
            $table->comment = '健康笔记点赞记录表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('health_note');
        Schema::dropIfExists('health_note_comments');
        Schema::dropIfExists('health_note_favorites');
    }
}
